<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title></title>
	<link href="estilos/planodeaula.css" type="text/css" rel="stylesheet"/>
	<!-- Calend�rio -->
  		<link rel="stylesheet" href="estilos/jquery-ui.css" />
  		<script src="js/jquery-1.9.1.js"></script>
  		<script src="js/jquery-ui.js"></script>
  		<script src="js/dataPicker.js"></script>
  		
	<?php
		session_start();
		include_once 'function/RecuperaCadastro.php';
		include_once '../gerenciadores/AutoloadGerenciadores.php';
		include_once 'function/data.php';

		
		if(isset($_POST['id'])){
			$tabData = $_POST['data'];
			$tabQtdAulas = $_POST['qtdAulas'];
			$tabMetodologia = $_POST['metodologia'];
			$tabMeios = $_POST['meios'];
			$tabAvaliacao = $_POST['avaliacao'];
			$tabTurno = $_POST['turno'];
			
			$tabIdPlano = $_POST['id'];
			foreach ($tabIdPlano as $idPlano){
				
				__autoload("PlanoDeAula");
				__autoload("GerenciadorDeInstrutores");

				$ger = new GerenciadorDeInstrutores();
				
				$plano = new PlanoDeAula();
				$plano->setIdPlano($idPlano);
				$plano->setDataAula(converteData($tabData[$idPlano]));
				$plano->setQtdAulas($tabQtdAulas[$idPlano]);
				$plano->setTurno($tabTurno[$idPlano]);
				$plano->setObjetivo($tabObjetivo[$idPlano]);
				$plano->setMetodologia($tabMetodologia[$idPlano]);
				$plano->setMeios($tabMeios[$idPlano]);
				$plano->setAvaliacao($tabAvaliacao[$idPlano]);
			
				
				$ger->atualizaPlano($plano);
			}
		} 
	?>
	</head>
	<body>
		<h1>Plano de Aula</h1>
		<form action="#" method="post">
			<table summary="plano_de_aula" id="plano_de_aula" border="1">

				<?php
					
				$cabecalhoTabela = "<tr>
					<th>Sel.:</th><th>Data da Aula:</th><th>Turno</th><th>Qtd de Aulas</th><th>Disciplina</th><th>Turma</th>
					<th>Conteudo</th><th>Objetivos</th>
					<th>Metodologia</th><th>Recursos</th><th>Avalia��o</th><th>Envio</th>
					</tr>";
				
					
				__autoload("Cadastro");
				__autoload("GerenciadorDeInstrutores");
				__autoload("PlanoDeAula");
				
				$tabCadastro = unserialize($_SESSION["cadastro"]);
				$cadastro = recuperaCadastro($tabCadastro);
				
				$ger = new GerenciadorDeInstrutores();
								
				$inscricao = array();
				foreach ($cadastro as $linha){
					if(!is_null($ger->getInscricao($linha))){
						$inscricao = array_merge($inscricao, $ger->getInscricao($linha));
					}
						
				}
									
				
				$i=0;
				$disciplina = null;
			
				
				foreach ($inscricao as $linha){
					$cadastro = $linha->getCadastro();
					
					if(isset($disciplina) || $disciplina!=$linha->getDisciplina()
							|| $turma!=$cadastro->getTurma()){
						echo $cabecalhoTabela;
						$turma = $cadastro->getTurma();
					}
					$disciplina = $linha->getDisciplina();
					$tabPlano = $ger->imprimePlano($linha);
					foreach ($tabPlano as $plano){
						echo "<tr>".
								"<td><input type='checkbox' name='id[]' value='".$plano->getIdPlano()."'></td>".
								"<td><input type='text' size='10' class='data' name='data[".$plano->getIdPlano()."]' value='".exibeData($plano->getDataAula())."'></td>".
								"<td><select name='turno[".$plano->getIdPlano()."]'>".
								"<option value=1 "; if($plano->getTurno()==1){echo "selected";}
								echo ">Manhã</option>".
								"<option value=2 "; if($plano->getTurno()==2){echo "selected";}
								echo ">Tarde</option>".
								"<option value=3 "; if($plano->getTurno()==3){echo "selected";}
								echo ">Noite</option>".
								"</select>".
								"<td><input type='text' size='2' name='qtdAulas[".$plano->getIdPlano()."]' value='".$plano->getQtdAulas()."'></td>".
								"<td><textarea rows='5' cols='10' disabled>".$plano->getDisciplina()."</textarea></td>".
								"<td><textarea rows='5' cols='10' disabled>".$plano->getTurma()."</textarea></td>".
								"<td><textarea rows='5' cols='60' maxlength='500' disabled>".$plano->getAssunto()."</textarea></td>".
								"<td><textarea rows='5' cols='60' maxlength='500' disabled]'>".$plano->getObjetivo()."</textarea></td>".
								"<td><textarea rows='5' cols='60' maxlength='500' name='metodologia[".$plano->getIdPlano()."]'>".$plano->getMetodologia()."</textarea></td>".
								"<td><textarea rows='5' cols='60' maxlength='500' name='meios[".$plano->getIdPlano()."]'>".$plano->getMeios()."</textarea></td>".
								"<td><textarea rows='5' cols='60' maxlength='500' name='avaliacao[".$plano->getIdPlano()."]'>".$plano->getAvaliacao()."</textarea></td>".
								"<td><input type='text' size='10' name='dataEnvio[".$plano->getIdPlano()."]' value='".exibeData($plano->getDataEnvio())."' disabled></td>".
								"</tr>";
					}
				}
				?>
			</table>
			<input type="submit" value="Confirma" class="botao">
		</form>
	</body>
</html>